#pragma once

#include <SFML/Audio.hpp>
#include <iomanip>
#include <iostream>
#include "WaveSample.h"



class Note
{
public:
	Note(void);
	~Note(void);

	void InitSample(int NbSamples, int Rate);//creates silent sample of length NbSamples
	short* GetData();//return short array of audio samples
	int GetSampleLength();//return audio sample array length
	void GetSFMLData(sf::SoundStream::Chunk& Data);//returns sample in SFML format

	void SawTooth(int Frequency, int Range);
	void Triangular(int Frequency, int Range);
	void Square(int Frequency, int Range);
	void TriSquare(int Frequency, int Range);
	void QuadSquare(int Frequency, int Range);
	void WhiteNoise(int Range);

	void SetNote(int NbSamples, int Rate, int frequency, int WhiteNoiseRange, int TriangularRange, int SawToothRange);	
	void RandomNote(bool save);

	void CrossFade(Note* oldNote, int oldNoteIndex, int length);
	void AddComponents(WaveComponent* component, int componentCount);
	void AddComponent(WaveComponent* component);

	void Smooth(int threshold);
	static void Smooth(short* sample, int sampleLength, int threshold);
private:
	int Rate;
	int NbSamples;
	short* Samples;
};
